//
//  LWX_VideoCell.m
//  Otaku
//
//  Created by lanou3g on 16/5/7.
//  Copyright © 2016年 Liuwx. All rights reserved.
//

#import "LWX_VideoCell.h"
#import "LWX_VideoModel.h"
@interface LWX_VideoCell()<VideoTableViewCellDelegate>
@property (weak, nonatomic) IBOutlet UIImageView *userImageView;
@property (weak, nonatomic) IBOutlet UILabel *userName;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *detailsLabel;
@property (weak, nonatomic) IBOutlet UILabel *praiseCountLabel;
@property (weak, nonatomic) IBOutlet UILabel *noPraiseCountLabel;

@property (weak, nonatomic) IBOutlet UILabel *redCountLabel;
@property (weak, nonatomic) IBOutlet UILabel *shareCountLabel;
@property (weak, nonatomic) IBOutlet UIImageView *videoImageView;
@property (weak, nonatomic) IBOutlet UILabel *playCountLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;




@end

@implementation LWX_VideoCell

+ (instancetype)cell {
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject];
}

- (void)awakeFromNib {
    self.userName.textColor = [UIColor colorWithRed:243/255.0 green:75/255.0 blue:80/255.0 alpha:1.0];
    self.autoresizingMask = NO;
    self.autoresizesSubviews = NO;
    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.image = [UIImage imageNamed:@"mainCellBackground"];
    self.backgroundView = imageView;
    
}


- (void)setModel:(LWX_VideoModel *)model{
    _model = model;
    self.userImageView.layer.cornerRadius = 15;
    self.userImageView.layer.masksToBounds = YES;
    [self.userImageView sd_setImageWithURL:[NSURL URLWithString:model.user[@"avatar_url"]]];
    self.userName.text = model.user[@"name"];
    self.titleLabel.text = model.text;
    self.detailsLabel.text = model.category_name;
    NSInteger count = model.digg_count;
    if (count > 10000) {
        self.praiseCountLabel.text = [NSString stringWithFormat:@"%ld万",model.digg_count / 10000];
        
    }else {
        self.praiseCountLabel.text = [NSString stringWithFormat:@"%ld",model.digg_count];
    }
    self.noPraiseCountLabel.text = [NSString stringWithFormat:@"%ld",model.bury_count];
    self.redCountLabel.text = [NSString stringWithFormat:@"%ld",model.comment_count];
    self.shareCountLabel.text = [NSString stringWithFormat:@"%ld",model.share_count];
    self.playCountLabel.text = [NSString stringWithFormat:@"%ld 次播放",model.play_count];
    self.timeLabel.text = [NSString stringWithFormat:@"%02ld:%02ld",model.duration / 60,model.duration % 60];

}



// 开始播放按钮
- (IBAction)startBtnAction:(id)sender {
    if ([self.delegate respondsToSelector:@selector(clickVideoButton:)]) {
        [self.delegate clickVideoButton:self.indexPath];
    }

}
// 赞
- (IBAction)praiseBtnAction:(id)sender {
    UIButton *button = (UIButton *)sender;
    button.selected = !button.selected;
}
// 不赞
- (IBAction)noPraiseBtnAction:(id)sender {
    
    UIButton *button = (UIButton *)sender;
    button.selected = !button.selected;
}
// 热
- (IBAction)redBtnAction:(id)sender {
    if ([self.delegate respondsToSelector:@selector(clickRedButton:)]) {
        [self.delegate clickRedButton:self.indexPath];
    }
    
    
}




- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
